package com.example.test2;

import java.util.function.Consumer;

public class ConsumerTest {

    public static void main(String[] args) {

        test1(msg -> System.out.println(msg + "转小写" + msg.toLowerCase()));
        test2(msg1 -> System.out.println(msg1 + "转小写" + msg1.toLowerCase()),
                msg2 -> System.out.println(msg2 + "转大写" + msg2.toUpperCase()));

    }

    private static void test1(Consumer<String> consumer) {
        consumer.accept("Hello World");
    }

    private static void test2(Consumer<String> c1, Consumer<String> c2) {
        /*
        c1.accept("Hello World");
        c2.accept("Hello World");
         */
        // 等同于
        c1.andThen(c2).accept("Hello Java");
    }
}
